﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HotelMap.aspx.cs" Inherits="simpleHotel.Web.HotelMap" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
      	<title>Find latitude and longitude with Google Maps</title>
    <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=AIzaSyB-azYlvwpdHMVzyeCAn6yqYR6euvIxA4I" type="text/javascript"></script>
    <script type="text/javascript">

        function load() {
            if (GBrowserIsCompatible()) {
                var map = new GMap2(document.getElementById("map"));
                map.addControl(new GSmallMapControl());
                map.addControl(new GMapTypeControl());
                var center = new GLatLng(48.89364, 2.33739);
                map.setCenter(center, 15);
                geocoder = new GClientGeocoder();
                var marker = new GMarker(center, { draggable: false });
                map.addOverlay(marker);
                document.getElementById("lat").innerHTML = center.lat().toFixed(5);
                document.getElementById("lng").innerHTML = center.lng().toFixed(5);


                /*GEvent.addListener(marker, "dragend", function() {
                 var point = marker.getPoint();
                    map.panTo(point);
                 document.getElementById("lat").innerHTML = point.lat().toFixed(5);
                 document.getElementById("lng").innerHTML = point.lng().toFixed(5);
          
                  });*/


                /*GEvent.addListener(map, "moveend", function() {
                     map.clearOverlays();
               var center = map.getCenter();
                     var marker = new GMarker(center, {draggable: true});
                     map.addOverlay(marker);
                     document.getElementById("lat").innerHTML = center.lat().toFixed(5);
                  document.getElementById("lng").innerHTML = center.lng().toFixed(5);
           
           
                GEvent.addListener(marker, "dragend", function() {
                 var point =marker.getPoint();
                    map.panTo(point);
                 document.getElementById("lat").innerHTML = point.lat().toFixed(5);
                    document.getElementById("lng").innerHTML = point.lng().toFixed(5);
           
                   });
            
                   });*/

            }

            showAddress('<%=HotelName%>','<%=Add%>');
        }



        var onMarkerClick = function () {

            infoWindow.setContent('<h3>Marker position is:</h3>');

            infoWindow.open(map, marker);
        };

        function showAddress(hotel,address) {


            var map = new GMap2(document.getElementById("map"));
            map.addControl(new GSmallMapControl());
            map.addControl(new GMapTypeControl());
            if (geocoder) {
                geocoder.getLatLng(
                  address,
                  function (point) {
                      if (!point) {
                          alert(address + " not found");
                      } else {
                              document.getElementById("lat").innerHTML = point.lat().toFixed(5);
                              document.getElementById("lng").innerHTML = point.lng().toFixed(5);
                              map.clearOverlays()
                              map.setCenter(point, 14);
                              map.setZoom(15);
                              var marker = new GMarker(point, { draggable: false });
                              map.addOverlay(marker);
                              map.openInfoWindow(map.getCenter(), '<div style="text-align:left;font-family:Verdana;font-size:11px"><b>'+hotel+'</b><br/>'+address+'</div>');
                             

                              GEvent.addListener(marker, 'click', function () {
                                  map.openInfoWindow(map.getCenter(), '<div style="text-align:left">' + hotel + '<br/>' + address + '</div>');
                              });
                                                          


                          /*GEvent.addListener(marker, "dragend", function() {
                        var pt = marker.getPoint();
                           map.panTo(pt);
                        document.getElementById("lat").innerHTML = pt.lat().toFixed(5);
                           document.getElementById("lng").innerHTML = pt.lng().toFixed(5);
                          });*/


                          /*GEvent.addListener(map, "moveend", function() {
                               map.clearOverlays();
                         var center = map.getCenter();
                               var marker = new GMarker(center, {draggable: true});
                               map.addOverlay(marker);
                               document.getElementById("lat").innerHTML = center.lat().toFixed(5);
                            document.getElementById("lng").innerHTML = center.lng().toFixed(5);
                     
                          GEvent.addListener(marker, "dragend", function() {
                          var pt = marker.getPoint();
                             map.panTo(pt);
                         document.getElementById("lat").innerHTML = pt.lat().toFixed(5);
                            document.getElementById("lng").innerHTML = pt.lng().toFixed(5);
                             });
                      
                             });*/

                      }
                  }
                );
            }
        }
    </script>
  
</head>

  
<body onload="load()" onunload="GUnload()">


 <p align="left">
 
 <table  bgcolor="#FFFFCC" width="300" style="display:none;">
  <tr>
    <td id="lat"></td>
    <td id="lng"></td>
  </tr>
</table>
 </p>
  <p>
  <div align="center" id="map" style="width: 100%; height: 600px"><br/></div>
   </p>
  
  <script type="text/javascript">
      //<![CDATA[
      if (typeof _gstat != "undefined") _gstat.audience('', 'pagesperso-orange.fr');
      //]]>
</script>
</body>

</html>

